package cn.butcher21.controller;

import cn.butcher21.dao.DaoWork;
import cn.butcher21.dao.DaoWorkImpl.DaoWorkImpl;
import cn.butcher21.pojo.Work;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.sql.SQLException;

/**
 * butcher create in 2021/04/10/22:41
 * <p>
 * 添加任务点
 */
@WebServlet("/add")
public class AddServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String msg = request.getParameter("msg");
        Gson gson = new Gson();
        Work work = gson.fromJson(msg, Work.class);
        DaoWork daoWork = new DaoWorkImpl();
        try {
            daoWork.add(work);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
